package com.zhubayi.service.impl;

import com.zhubayi.entity.History;
import com.zhubayi.entity.Video;
import com.zhubayi.entity.vo.HistoryVo;
import com.zhubayi.entity.vo.VideoVo;
import com.zhubayi.mapper.HistoryMapper;
import com.zhubayi.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 祝八一
 */
@Service
public class HistoryServiceImpl implements HistoryService {
    @Autowired
    HistoryMapper historyMapper;

    @Override
    public void add(Integer Uid, Integer vid) {
        //先查找在不在
       History history= historyMapper.queryByUidAndId(Uid,vid);
       if (history==null){
           historyMapper.add(Uid,vid,new Date());

       }else {
           historyMapper.update(Uid,vid,new Date());
       }
    }

    @Override
    public void update(Integer Uid, Integer Vid) {
        historyMapper.update(Uid,Vid,new Date());
    }

    @Override
    public void delete(Integer Uid, Integer Vid) {
        historyMapper.delete(Uid, Vid);
    }

    @Override
    public List<HistoryVo> queryByUid(Integer Uid) {
        return historyMapper.queryByUid(Uid);
    }
}
